﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Graphics;

namespace Lucy.Engine.Framework
{
    public class Scene : PropertyObject
    {
        public string Name { get; set; }
        public List<Layer> Layers { get; private set; }

        public Scene()
        {
            Layers = new List<Layer>();
            Name = "Scene 1";
        }

        public void AddLayer(Layer layer)
        {
            Layers.Add(layer);
        }

        public void Update(float elapsed)
        {
            foreach (Layer layer in Layers)
            {
                foreach (GameObject gameObject in layer.GameObjects)
                {
                    foreach (Component component in gameObject.Components)
                    {
                        component.OnUpdate(elapsed, gameObject);
                    }
                }
            }
        }

        public void Render(SpriteBatch spriteBatch)
        {
            foreach (Layer layer in Layers)
            {
                foreach (GameObject gameObject in layer.GameObjects)
                {
                    foreach (Component component in gameObject.Components)
                    {
                        component.OnRender(spriteBatch, gameObject);
                    }
                }
            }
        }

        public override IEnumerable<string> GetProperties()
        {
            yield return null;
        }

        public override void SetValue(string propertyName, string value)
        {
            
        }

        public override string GetValue(string propertyName)
        {
            return String.Empty;
        }
    }
}
